﻿<Window x:Class="ttg_internal.Utilities.PipelineManager.View.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:convert="clr-namespace:ttg_internal.Utilities.PipelineManager.Converters"
    xmlns:diagram="clr-namespace:ttg_internal.Utilities.PipelineManager.Diagram"
    xmlns:helpers="clr-namespace:ttg_internal.Utilities.PipelineManager.Helpers"
    xmlns:utils="clr-namespace:ttg_internal.utils;assembly=UtilManager"
    Height="600" Width="800" Title="Pipeline manager">
    
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Utilities.Common;component/Styles/DefaultStyles.xaml" />
                <ResourceDictionary Source="/Utilities.Common;component/Styles/CustomStyles.xaml" />
                <ResourceDictionary Source="/Utilities.PipelineManager;component/Themes/Generic.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="220" />
        </Grid.ColumnDefinitions>

        <GroupBox Header="Pipelines" Grid.Column="0">
            <TreeView x:Name="PipelineTree" ItemsSource="{Binding Pipelines}">
                <TreeView.Resources>
                    <HierarchicalDataTemplate DataType="{x:Type utils:Pipeline}" ItemsSource="{Binding SubPipelines}">
                        <ContentPresenter Content="{Binding Name}" />
                    </HierarchicalDataTemplate>
                    <DataTemplate DataType="{x:Type utils:SubPipeline}">
                        <ContentPresenter Content="{Binding Name}" />
                    </DataTemplate>
                </TreeView.Resources>
            </TreeView>
        </GroupBox>
        <GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="0.5" Grid.Column="0" />

        <GroupBox Header="Presentation" Grid.Column="1">
            <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                <ScrollViewer.Resources>
                    <convert:PipelineConverter x:Key="PipelineConverter" />
                </ScrollViewer.Resources>
                
                <diagram:DesignerCanvas x:Name="Canvas" Background="Transparent" Margin="10"
                                        HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                        helpers:CanvasHelper.Children="{Binding SelectedItem.Nodes, ElementName=PipelineTree, Converter={StaticResource PipelineConverter}}" />
            </ScrollViewer>
        </GroupBox>

        <GroupBox DataContext="{Binding SelectedItems[0].DataContext, ElementName=Canvas}" Header="Properties" Grid.Column="2">
            <Grid Margin="0,5,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="2*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                
                <Label Content="Name" VerticalAlignment="Center" Grid.Column="0" Grid.Row="0" />
                <TextBox IsReadOnly="True" Margin="0,2,0,2" Text="{Binding Name, Mode=OneWay}" Grid.Column="1" Grid.Row="0" />

                <Label Content="Usage" VerticalAlignment="Center" Grid.Column="0" Grid.Row="1" />
                <TextBox Margin="0,2,0,2" Text="{Binding Usage, StringFormat=F2, Mode=TwoWay}" Grid.Column="1" Grid.Row="1" />

                <Label Content="Active Task Count" VerticalAlignment="Center" Grid.Column="0" Grid.Row="2" />
                <TextBox Margin="0,2,0,2" Text="{Binding ActiveTaskCount, Mode=TwoWay}" Grid.Column="1" Grid.Row="2" />
            </Grid>
        </GroupBox>
        <GridSplitter HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="0.5" Grid.Column="2" />
    </Grid>
</Window>